import http from './http.js'
import qs from 'qs'
// 角色
const GET_ROLE = '/water/role/findAll' //查询所有角色
const ADD_ROLE = '/water/role/add' //添加角色
const DELETE_ROLE = '/water/role/deleteById' //删除角色(并且删除其拥有的权限)
const FIND_ROLE_PERMISSION = '/water/role/findRolePermissionById' //查看角色拥有的权限
const UPDATE_PERMISSION = '/water/role/updatePermission' //给角色授权,新增和修改都是这个接口
// 菜单
const GET_MENU = '/water/menu/getUserMenu' //查询用户菜单
// 用户管理
const LOGINURL = '/water/admin/login' //登录
const SEND_CODE = '/water/code/sendCode' // 发送验证码(短信平台,没钱,所以默认123456)
const CHECK_CODE = '/water/code/checkCode' //验证码是否正确
const RESET_PASSWORD = '/water/admin/forgotPassword' //忘记密码
const ADD_ACCOUNT = '/water/admin/add' //添加用户信息
const CHECK_PHONE = '/water/admin/checkPhone' //验证手机是否已被使用,true已被使用,false未被使用
const LOGOUT = '/water/admin/logout' //退出登录
const UPDATE_ACCOUNT = '/water/admin/update' //修改用户信息
const DELETE_ACCOUNT = '/water/admin/updateState' //修改用户状态,假删除
const QUERY_PAGE_ACCOUNT = '/water/admin/queryPage' //查询用户信息
// 客户类型管理
const CUSTOMER_TYPE_QUERY = '/water/customerType/query'
const CUSTOMER_TYPE_DELETE = '/water/customerType/deleteById'
const CUSTOMER_TYPE_ADD = '/water/customerType/add'
const CUSTOMER_TYPE_UPDATE = '/water/customerType/update'
const CUSTOMER_TYPE_QUERYPAGE = '/water/customerType/queryPage'
// 客户管理：
const CUSTOMER_DOWNLOAD_EXECL = '/water/customer/downloadExcel' //导出Excel客户
const CUSTOMER_DOWNLOAD_MODEL = '/water/customer/downloadModel' // 下载上传的模板
const CUSTOMER_SELECT = '/water/customer/select' // 查询客户
const CUSTOMER_SELECTINFO = '/water/customer/selectInfo' //根据客户编号,查询客户详情(客户类型,水表详情等)
const CUSTOMER_UN_OR_BINDING = '/water/customer/unOrBinding' //给客户绑定新水表或者解绑水表
const CUSTOMER_UPDATE = '/water/customer/updateById' //修改客户信息
const CUSTOMER_UPLOAD_EXECL = '/water/customer/upLoadExcel' //导入Excel客户
const CUSTOMER_ADD = '/water/customer/add' //添加客户信息

// 水表类型管理：
const WATER_WATERTYPE_ADD = '/water/waterType/add' //添加水表类型
const WATER_WATERTYPE_DELETE = '/water/waterType/deleteById' //删除水表类型
const WATER_WATERTYPE_QUERY = '/water/waterType/query' //查询全部水表类型
const WATER_WATERTYPE_QUERYPAGE = '/water/waterType/queryPage' //分页查询水表类型
const WATER_WATERTYPE_UPDATE = '/water/waterType/update' // 修改水表类型

// 水表管理：
const WATER_WATERMETER_QUERYPAGE = '/water/waterMeter/queryPage' //查询水表(水表类型,水表详情等)
const WATER_WATERMETER_QUERYBYID = '/water/waterMeter/queryById' //根据id查询水表(水表类型,客户信息,水表详情等)
const WATER_WATERMETER_DOWNLOADMODEL = '/water/waterMeter/downloadModel' //下载导入模板
const WATER_WATERMETER_DOWNLOADEXECL = '/water/waterMeter/downloadExcel' //导出Excel水表信息
const WATER_WATERMETER_UPLOADEXECL = '/water/waterMeter/upLoadExcel' //导入Excel水表信息
const WATER_WATERMETER_UPDATE = '/water/waterMeter/update' // 修改水表信息
const WATER_WATERMETER_ADD = '/water/waterMeter/add' //添加水表信息
const WATER_WATERMETER_QUERY_BYID_UNBINDING = '/water/waterMeter/queryByIdUnBinding' //根据编号查询未被绑定的水表
const WATER_WATERMETER_UPLOAD_CONTRACT = '/water/waterMeter/uploadContract'
// 联系人管理
const WATER_ASSOCIATED_ADD = '/water/associated/add' //添加联系人
const WATER_ASSOCIATED_DISASSOCIATE = '/water/associated/disassociate' //解除关联

// 计费类型管理
const WATER_BILLING_TYPE_ADD = '/water/billingType/add' //添加计费类型
const WATER_BILLING_TYPE_DELETE = '/water/billingType/deleteById' //删除计费类型
const WATER_BILLING_TYPE_QUERY = '/water/billingType/query' // 查询全部计费类型
const WATER_BILLING_TYPE_QUERY_PAGE = '/water/billingType/queryPage' // 分页查询计费类型
const WATER_BILLING_TYPE_UPDATE = '/water/billingType/update' //修改计费类型

// 基价设置
const WATER_BILLING_BASE_PRICE_ABOLISH = '/water/billingBasePrice/abolish' // 基价作废
const WATER_BILLING_BASE_PRICE_ADD = '/water/billingBasePrice/add' // 添加基价
const WATER_BILLING_BASE_PRICE_ENABLE = '/water/billingBasePrice/enable' //基价启动(恢复)
const WATER_BILLING_BASE_PRICE_QUERYPAGE = '/water/billingBasePrice/queryPage' //查询基价
const WATER_BILLING_BASE_PRICE_QUERY = '/water/billingBasePrice/query' //查询基价(下拉框接口)
// 地域管理
const WATER_REGION_ADD = 'water/region/add' //添加管理区域
const WATER_REGION_DELBYID = '/water/region/delById' // 删除管理区域
const WATER_REGION_QUERY_ID = '/water/region/queryById' // 根据id查询理区域信息
const WATER_REGION_QUERY_CHILDREN_REGIN = '/water/region/queryChildrenRegion' // 根据父级id查询子集目录
const WATER_REGION_QUERY_ROOT_REGION = '/water/region/queryRootRegion' // 查询根目录地区

// 抄表接口API Record Controller
const WATER_RECORD_CONFIRM_RECORD = '/water/record/confirmRecord' //读数确认
const WATER_RECORD_ISNOWMONTH = '/water/record/isNowMonth' //查询当月是否已提交抄表
const WATER_RECORD_QUERY_PAGE = '/water/record/queryPage' // 查询抄表记录
const WATER_RECORD_UPLOAD_RECORD = '/water/record/uploadRecord' //上传上月度数图片
const WATER_RECORD_WRITE_RECORD = '/water/record/writeRecord' //上传上月填写度数

// 账单、缴费管理
const WATER_BILL_QUERYPAGE = '/water/bill/queryPage' //查询账单
const WATER_BILL_DEDUCTION_AMOUNT = '/water/bill/deductionAmount' //减免金额
const WATER_BILL_PAY = '/water/bill/pay' //缴费
// 通知公告接口API Notice Controller
const WATER_NOTICE_ADD = '/water/notice/add' //添加通知公告
const WATER_NOTICE_DELETE_ID = '/water/notice/deleteById' // 删除通知公告
const WATER_NOTICE_QUERY = '/water/notice/query' //根据id查询通知公告
const WATER_NOTICE_QUERYPAGE = '/water/notice/queryPage' // 分页查询通知公告
const WATER_NOTICE_UPDATE = '/water/notice/update' // 修改通知公告

// 统计
const WATER_CENSUS_HOME_NUMBER = `water/census/homeCensusNumber` //主页统计信息;
const WATER_CENSUS_COLUMNAR_ECHARTS = '/water/census/censusColumnarEcharts' //按客户类型来统计;上月用水量(饼图);
const WATER_CENSUS_MAP_ECHARTS = '/water/census/censusMapEcharts' //按一级城市区域统计上月用水量;上月用水量(地图);
const WATE_CENSUS_TYPE_COLUMNAR_ECHARTS = '/water/census/censusTypeColumnarEcharts' //按用水类型统计;上月用水量(柱状图);
const WATER_CENSUS_YEAR_SECTOR_ECHARTS = '/water/census/censusYearSectorEcharts' //按年对比统计分析12个月用水量;上月用水量(波浪图);

/**
 * 登录
 * @param {String} phone
 * @param {String} password
 * @returns
 */
export const login = params => {
  return http({
    url: LOGINURL,
    method: 'post',
    // data: Qs.stringify(params),  // data 要加Qs.stringify()来序列化参数才可以让参数拼接再?后面
    params: params
  })
}
/**
 * 获取验证码
 * @pramas {String} phone ,require
 */
export const getCheckCode = params => {
  return http({
    url: SEND_CODE,
    method: 'post',
    params
  })
}
/**
 * 检查验证码
 * @params {String} phone,required
 * @params {String} code,required
 */
export const checkCode = params => {
  return http({
    url: CHECK_CODE,
    method: 'post',
    params
  })
}
/**
 * 重置密码
 * @params {String} phone,required
 * @params {String} password,required
 */
export const resetPassword = params => {
  return http({
    url: RESET_PASSWORD,
    method: 'post',
    params
  })
}
/**
 * 获取用户对应权限的菜单
 */
export const getMenu = () => {
  return http({
    url: GET_MENU,
    method: 'get'
  })
}
/**
 * 分页查询客户类型
 * @param {Number} pageNum 当前页
 * @param {Number} pageSize 每页条数
 * @returns
 */
export const getCustomerTypePage = params => {
  return http({
    url: CUSTOMER_TYPE_QUERYPAGE,
    method: 'get',
    params: params
  })
}

//查询全部客户类型
export const getCustomerType = () => {
  return http({
    url: CUSTOMER_TYPE_QUERY,
    method: 'get'
  })
}

/**
 *删除客户类型
 * @param {Number} customerTypeId
 * @returns
 */
export const deleteCustomerType = params => {
  return http({
    url: CUSTOMER_TYPE_DELETE,
    method: 'get',
    params: params
  })
}

/**
 *添加客户类型
 * @param {String} customerTypeName
 * @returns
 */
export const addCustomerType = params => {
  return http({
    url: CUSTOMER_TYPE_ADD,
    method: 'post',
    params: params
  })
}

/**
 * 更新客户类型
 * @param {Number} customerTypeId
 * @param {String} customerTypeName
 * @returns
 */
export const updateCustomerType = params => {
  return http({
    url: CUSTOMER_TYPE_UPDATE,
    method: 'post',
    params: params
  })
}
/**
 * 查询客户
 * @param {String} address,
 * @param {String} createTime,
 * @param {String} name,
 * @param {String} phone,
 * @param {String} state,
 * @param {Number} pageNum ,required
 * @param {Number} pageSize,required
 * @returns
 */
export const getCustomer = params => {
  return http({
    url: CUSTOMER_SELECT,
    method: 'get',
    params
  })
}
/**
 * 添加客户信息， 所有参数都必传
 * @param {String} customerName , 客户名称
 * @param {String} customerPhone , 客户手机号码
 * @param {Number} customerTypeId , 客户类型ID
 * @param {String} customerIdCard , 客户身份证号码
 * @param {String} customerAddress , 客户三级地址中第三级的ID
 * @param {String} customerAddressInfo  , 客户详细地址
 *
 */
export const addCustomer = params => {
  return http({
    url: CUSTOMER_ADD,
    method: 'POST',
    params
  })
}
/**
 * 查看指定ID的客户信息
 * @param {Number} customerId , required 客户ID
 * @returns
 */
export const getCustomerInfo = params => {
  return http({
    url: CUSTOMER_SELECTINFO,
    method: 'get',
    params
  })
}

/**
 * 编辑客户信息
 * @param {String} address ,required 客户地址
 * @param {String} phone,required 手机号码
 * @param {String} changeInfo,required 改变原因
 * @param {Number} state,required 客户状态
 * @param {Number} customerId,required 客户ID
 * @param {Number} customerTypeId,required 客户类型ID
 * @returns
 */
export const updateCustomerInfo = params => {
  return http({
    url: CUSTOMER_UPDATE,
    method: 'post',
    params
    // paramsSerializer: {
    //   serialize: params => {
    //     return qs.stringify(params, { indices: false })
    //   }
    // }
  })
}
/**
 * 导出Excel客户
 */
export const downloadCustomerExcel = () => {
  return http({
    url: CUSTOMER_DOWNLOAD_EXECL,
    method: 'get',
    responseType: 'blob'
    // eslint-disable-next-line
    // 响应类型，blob 二进制的流文件, 如果不指定，res打出来看，就是乱码，指定响应类型后，就是： Blob {size: 5342, type: 'application/octet-stream'}
  })
}
/**
 * 下载Excel客户上传模板
 */
export const downloadCustomerModel = () => {
  return http({
    url: CUSTOMER_DOWNLOAD_MODEL,
    method: 'get',
    responseType: 'blob'
  })
}

/**
 * 下载Excel客户上传模板
 */
export const uploadCustomerExecl = (formdata, params = {}) => {
  return http({
    url: CUSTOMER_UPLOAD_EXECL,
    method: 'post',
    data: formdata,
    // 在使用formData数据做参数时，直接把对象赋值给data属性
    // 同时，不要headers: {'content-type':'multipart/formdata'},写了，不能正常上传文件。
    //不写，则由axios自动识别，选择正确headers调接口。
    params: params
  })
}

/**
 * 客户绑定或解绑水表
 * @param {Number} customerId  ,客户ID
 * @param {boolean} state   ,true绑定,false解绑
 * @param {Array} waterNumberArr   ,水表编号，需要配置序列化参数的方式，不然参数给后端就显示为 waterNumberArr[]:00123,waterNumberArr[]:001234，去掉[]，就需要做下面的配置。
 */
export const customerBindOrUnbind = params => {
  return http({
    url: CUSTOMER_UN_OR_BINDING,
    method: 'get',
    params: params,
    // paramsSerializer再新版本里面，要写成对象格式，不是函数
    paramsSerializer: {
      serialize: params => {
        // return qs.stringify(params, { arrayFormat: 'repeat' })
        return qs.stringify(params, { indices: false })
      }
    }
  })
}
/**
 * 获取所有水表类型数据
 * @returns
 */
export const getWaterTypeList = () => {
  return http({
    url: WATER_WATERTYPE_QUERY,
    method: 'get'
  })
}
/**
 * 分页获取一页水表类型数据
 * @param {Number} pageNum,required
 * @param {Number} pageSize ,required
 * @returns
 */
export const getWaterTypeListPage = params => {
  return http({
    url: WATER_WATERTYPE_QUERYPAGE,
    method: 'get',
    params
  })
}
/**
 * 删除一个水表类型
 * @param {Number} waterTypeId ,required
 * @returns
 */
export const deleteWaterType = params => {
  return http({
    url: WATER_WATERTYPE_DELETE,
    method: 'get',
    params
  })
}
/**
 * 添加水表类型
 * @param {*} params
 * @returns
 */
export const addWaterType = (params, data) => {
  return http({
    url: WATER_WATERTYPE_ADD,
    method: 'post',
    params,
    data
  })
}
/**
 * 修改水表类型
 * @param {*} params
 * @returns
 */
export const updateWaterType = (params, data) => {
  return http({
    url: WATER_WATERTYPE_UPDATE,
    method: 'post',
    params,
    data
  })
}

/**
 * 查询水表(水表类型,水表详情等)
 * @param {Number} pageNum, require
 * @param {Number} pageSize, require
 * @param {String}  waterNumber 水表编号
 * @param {String} customerName 客户名称
 * @param {Boolean} binding 绑定状态
 */
export const getWaterMeterList = params => {
  return http({
    url: WATER_WATERMETER_QUERYPAGE,
    method: 'get',
    params
  })
}
//
/**
 * 根据编号查询未被绑定的水表
 * @param {string} waterNumber ,required 水表编号
 */
export const getUnBindingWaterMeterDetailInfo = params => {
  return http({
    url: WATER_WATERMETER_QUERY_BYID_UNBINDING,
    method: 'get',
    params,
    paramsSerializer: {
      serialize: params => {
        return qs.stringify(params, { indices: false })
      }
    }
  })
}
/**
 * 根据id查询水表(水表类型,客户信息,水表详情等)
 * @param {string} waterNumber ,required
 */
export const getWaterMeterDetailInfo = params => {
  return http({
    url: WATER_WATERMETER_QUERYBYID,
    method: 'get',
    params
  })
}

/**
 * 修改水表信息
 * @param {string} address  ,required，客户地址:第三级id
 * @param {string} addressInfo 第三级id
 * @param {Number} billingId   ,required，计费类型id
 * @param {string} changeInfo   ,required，更变原因
 * @param {Number} waterId   ,required，水表id
 *
 */
export const editWaterMeterInfo = params => {
  return http({
    url: WATER_WATERMETER_UPDATE,
    method: 'POST',
    params
  })
}

/**
 * 添加水表信息
 * @param {Number} billingId   ,计费类型id
 * @param {Number} customerId   ,客户编号,可以不填
 * @param {Number} waterInitialCount    ,required,初始度数
 * @param {string} waterInstallAddress   ,安装地址:第三级id
 * @param {string} waterInstallAddressInfo   ,安装详细地址,可不填
 * @param {string} waterInstallTime   ,安装时间,可不填
 * @param {string} waterNumber   required, 水表编号
 * @param {Number} waterTypeId    required,水表类型编号
 *
 */
export const addWaterMeterInfo = params => {
  return http({
    url: WATER_WATERMETER_ADD,
    method: 'POST',
    params
  })
}
/**
 * 下载水表模板
 */
export const downloadWaterMeterModel = () => {
  return http({
    url: WATER_WATERMETER_DOWNLOADMODEL,
    method: 'get',
    responseType: 'blob'
  })
}
/**
 * 导出Excel水表信息
 * @params {Boolean} binding
 * @params {String} customerName
 * @params {String} waterNumber
 */
export const downloadWaterMeterExecl = () => {
  return http({
    url: WATER_WATERMETER_DOWNLOADEXECL,
    method: 'get',
    responseType: 'blob'
  })
}

/**
 * 导入Excel水表信息
 * @param {FormData} file,required 

 */
export const uploadWaterMeterExecl = params => {
  return http({
    url: WATER_WATERMETER_UPLOADEXECL,
    method: 'post',
    data: params
  })
}

/**
 * 添加水表关联的联系人
 * @params {String} associatedName,联系人名字
 * @params {String} associatedPhone,联系人电话
 * @params {String} waterId,水表编号
 */
export const addAssociated = params => {
  return http({
    url: WATER_ASSOCIATED_ADD,
    method: 'post',
    params
  })
}

/**
 * 解除水表关联的关联人
 * @param {Number} associatedId ,required
 */
export const disAssociated = params => {
  return http({
    url: WATER_ASSOCIATED_DISASSOCIATE,
    method: 'get',
    params
  })
}
/**
 * 上传客户开户的水表合同
 * @param {FormData:body} file ,required,data:FormData has 'file' property.
 * @param {String:query} waterNumber ,required ,params:{waterNumber}
 *
 */
export const uploadCustomeForWaterMeterContract = (params, data) => {
  return http({
    url: WATER_WATERMETER_UPLOAD_CONTRACT,
    method: 'post',
    params,
    data
  })
}
//
/**
 * 添加计费类型
 * @param {String} billingTypeName  ,required 计费类型名称
 */
export const addBillingType = params => {
  return http({
    url: WATER_BILLING_TYPE_ADD,
    method: 'post',
    params
  })
}

/**
 * 分页查询计费类型数据
 * @param {Number} pageNum  ,required
 * @param {Number} pageSize  ,required
 *
 */
export const getBillingTypeListPage = params => {
  return http({
    url: WATER_BILLING_TYPE_QUERY_PAGE,
    method: 'get',
    params
  })
}

/**
 * 不分页查询计费类型数据
 */
export const getBillingTypeList = () => {
  return http({
    url: WATER_BILLING_TYPE_QUERY,
    method: 'get'
  })
}
/**
 * 删除计费类型
 * @param {Number} billingTypeId  ,required 计费类型ID
 */
export const delBillingType = params => {
  return http({
    url: WATER_BILLING_TYPE_DELETE,
    method: 'get',
    params
  })
}

/**
 * 更新计费类型
 * @param {Number} billingTypeId  ,required 计费类型ID
 * @param {String} billingTypeName,required 计费类型名称
 */
export const updateBillingType = params => {
  return http({
    url: WATER_BILLING_TYPE_UPDATE,
    method: 'post',
    params
  })
}

/**
 * 添加基价类型
 * @param {Number} billingTypeId  ,required 计费类型ID
 * @param {Number} customerTypeId   ,required 客户类型ID
 * @param {String} billingName ,required 基价名称
 * @param {Number} billingPrice ,required 基价价格
 */
export const addBilingBasePrice = params => {
  return http({
    url: WATER_BILLING_BASE_PRICE_ADD,
    method: 'post',
    params
  })
}
/**
 *  基价作废
 * @param {Number} billingId  ,required 基价ID
 */
export const abolishBilingBasePrice = params => {
  return http({
    url: WATER_BILLING_BASE_PRICE_ABOLISH,
    method: 'post',
    params
  })
}
/**
 *  基价恢复
 * @param {Number} billingId  ,required 基价ID
 */
export const enableBilingBasePrice = params => {
  return http({
    url: WATER_BILLING_BASE_PRICE_ENABLE,
    method: 'post',
    params
  })
}

/**
 *  查询所有基价
 * @param {String} billingName ,required 基价名称
 * @param {Number} billingPrice ,required 基价价格
 */
export const getBilingBasePrice = params => {
  return http({
    url: WATER_BILLING_BASE_PRICE_QUERYPAGE,
    method: 'get',
    params
  })
}
/**
 *  查询所有基价(计费类型),不分页
 * @param {String} billingName ,required 基价名称
 * @param {Number} billingPrice ,required 基价价格
 */
export const getBilingBasePriceNotPage = () => {
  return http({
    url: WATER_BILLING_BASE_PRICE_QUERY,
    method: 'get'
  })
}
/**
 *  添加一个区域地址
 * @param {String} regionName ,required 地址名称
 * @param {Number} regionParentId ,required 父级地址的ID
 */
export const addRegion = params => {
  return http({
    url: WATER_REGION_ADD,
    method: 'post',
    params
  })
}
/**
 *  删除区域地址
 * @param {Number} regionId ,required  地址的ID
 */
export const deleteRegion = params => {
  return http({
    url: WATER_REGION_DELBYID,
    method: 'get',
    params
  })
}
/**
 *  根据id查询理区域信息
 * @param {Number} regionId ,required  地址的ID
 */
export const queryRegion = params => {
  return http({
    url: WATER_REGION_QUERY_ID,
    method: 'get',
    params
  })
}
/**
 *  查询一个父级下所有子级区域地址
 * @param {Number} regionId ,required  地址的ID
 */
export const queryChildrenRegionAll = params => {
  return http({
    url: WATER_REGION_QUERY_CHILDREN_REGIN,
    method: 'get',
    params
  })
}
/**
 *  查询根目录地区
 */
export const queryRootRegionAll = params => {
  return http({
    url: WATER_REGION_QUERY_ROOT_REGION,
    method: 'get',
    params
  })
}

/**
 *  读数确认,默认状态时'已确认'
 * @params {Array[string]} recordIds,require 抄表记录ID
 */
export const waterRecordConfirmRecord = params => {
  return http({
    url: WATER_RECORD_CONFIRM_RECORD,
    method: 'post',
    params,
    paramsSerializer: {
      serialize: params => {
        return qs.stringify(params, { indices: false }) // 参数：false,显示为recordIds[]，ture:recordIds
      }
    }
  })
}
/**
 *  查询当月是否已提交抄表
 * @params {String} waterNumber,require 水表编号
 */
export const waterRecordIsNowMonth = params => {
  return http({
    url: WATER_RECORD_ISNOWMONTH,
    method: 'get',
    params
  })
}
/**
 *  查询抄表记录
 * @params {Number} pageSizde,require 每页几条
 * @params {Number} pageNum,require 当前页
 *
 */
export const waterRecodeQueryPage = params => {
  return http({
    url: WATER_RECORD_QUERY_PAGE,
    method: 'get',
    params
  })
}
/**
 *  上传上月度数图片
 * @params {String} waterNumber,require 水表编号
 * @params  {formData} file, 确认度数图片,
 */
export const waterRecodeUploadRecord = (params, formData) => {
  return http({
    url: WATER_RECORD_UPLOAD_RECORD,
    method: 'post',
    params, // {waterNumber:''}
    data: formData // {file}
  })
}
/**
 *  上传上月填写度数
 * @params {number } recordNow ,require  度数
 * @params {String} waterNumber,require 水表编号
 */
export const waterRecodeWriteRecord = params => {
  return http({
    url: WATER_RECORD_WRITE_RECORD,
    method: 'get',
    params
  })
}

/**
 *  查询账单记录
 * @params {Number} pageSizde,require 每页几条
 * @params {Number} pageNum,require 当前页
 * @params {String} recordTime 账单时间
 * @params {String} waterNumber 水表编号
 * @params {Number} recordState 状态
 */
export const waterBillQueryPage = params => {
  return http({
    url: WATER_BILL_QUERYPAGE,
    method: 'get',
    params
  })
}

/**
 *  减免金额接口
 * @params {Number} billId 账单ID
 * @params {Number} money 减免金额
 */
export const waterBillDeductionAmount = params => {
  return http({
    url: WATER_BILL_DEDUCTION_AMOUNT,
    method: 'get',
    params
  })
}
/**
 *  缴费接口
 * @params {Number} billId 账单ID
 * @params {Number} money 缴费金额
 */
export const waterBillPay = params => {
  return http({
    url: WATER_BILL_PAY,
    method: 'get',
    params
  })
}

/**
 *  添加通知公告
 * @params {String} adminId,require 管理员帐号 ,require
 * @params {String} noticeContent,require 公告内容,require
 * @params {Date-time} noticePublishTime, 公告发布时间,require
 * @params {Number} noticeState ,公告状态,require
 * @params {String} noticeTitle, 公告标题,require
 */
export const waterNoticeAdd = params => {
  return http({
    url: WATER_NOTICE_ADD,
    method: 'post',
    params
  })
}
/**
 *  删除通知公告
 * @params {Number} noticeId,公告id,添加可不填,修改必填,[修改时require]
 */
export const waterNoticeDelete = params => {
  return http({
    url: WATER_NOTICE_DELETE_ID,
    method: 'get',
    params
  })
}
/**
 *  根据ID查询通知公告
 * @params {Number} noticeId,公告id,添加可不填,修改必填,[修改时require]
 */
export const waterNoticeQuery = params => {
  return http({
    url: WATER_NOTICE_QUERY,
    method: 'get',
    params
  })
}
/**
 *  分页查询通知公告
 * @params {Number} pageNum, 当前页，require
 * @params {Number} pageSize, 每页几条，require
 * @params {date-time} noticePublishTime, 发布时间
 * @params {Number} noticeState, 公告状态
 * @params {String} noticeTitle, 公告标题
 */
export const waterNoticeQueryPage = params => {
  return http({
    url: WATER_NOTICE_QUERYPAGE,
    method: 'get',
    params
  })
}
/**
 *  修改通知公告
 * @params {String} adminId,require 管理员帐号 ,require
 * @params {String} noticeContent,require 公告内容,require
 * @params {Date-time} noticePublishTime, 公告发布时间,require
 * @params {Number} noticeState ,公告状态,require
 * @params {String} noticeTitle, 公告标题,require
 * @params {Number} noticeId,公告id,require
 */
export const waterNoticeUpdate = params => {
  return http({
    url: WATER_NOTICE_UPDATE,
    method: 'post',
    params
  })
}

/**
 * 添加用户信息
 * @param {String} adminName 系统用户名名称,required
 * @param {String} adminEmail 邮箱,required
 * @param {String} adminPhone 系统电话,密码是电话默认后6位,required
 * @param {Number} roleId 角色ID,required
 * @returns
 */
export const addAccount = params => {
  return http({
    url: ADD_ACCOUNT,
    method: 'post',
    params
  })
}
/**
 * 修改用户信息
 * @param {String} adminName 系统用户名名称,required
 * @param {String} adminEmail 邮箱,required
 * @param {String} adminPhone 系统电话,密码是电话默认后6位,required
 * @param {Number} roleId 角色ID,required
 * @param {Number} adminId 修改时填写,系统用户id ,required
 * @returns
 */
export const modifyAccount = params => {
  return http({
    url: UPDATE_ACCOUNT,
    method: 'post',
    params
  })
}
/**
 * 修改用户信息状态，即假删除
 * @param {Number} state 角色state,required， (0禁用,1正常)
 * @param {Number} adminId 系统用户id ,required
 * @returns
 */
export const editAccountState = params => {
  return http({
    url: DELETE_ACCOUNT,
    method: 'post',
    params
  })
}

/**
 *验证手机是否已被使用,true已被使用,false未被使用
 * @param {string} phone ，手机号码
 */
export const checkPhone = params => {
  return http({
    url: CHECK_PHONE,
    method: 'post',
    params
  })
}
/**
 * 退出系统
 * @returns
 */
export const logOut = params => {
  return http({
    url: LOGOUT,
    method: 'post',
    params
  })
}
/**
 *主页统计信息;
 * @returns
 */
export const homeCensusNumber = params => {
  return http({
    url: WATER_CENSUS_HOME_NUMBER,
    method: 'get',
    params
  })
}

/**
 *按客户类型来统计;上月用水量(饼图);
 */

export const censusColumnarEcharts = () => {
  return http({
    url: WATER_CENSUS_COLUMNAR_ECHARTS,
    method: 'GET'
  })
}

/**
 * 按一级城市区域统计上月用水量;上月用水量(地图);
 */

export const censusMapEcharts = () => {
  return http({
    url: WATER_CENSUS_MAP_ECHARTS,
    method: 'GET'
  })
}

/**
 * 按用水类型统计;上月用水量(柱状图);
 */

export const censusTypeColumnarEcharts = () => {
  return http({
    url: WATE_CENSUS_TYPE_COLUMNAR_ECHARTS,
    method: 'GET'
  })
}
/**
 * 按年对比统计分析12个月用水量;上月用水量(波浪图);
 */

export const censusYearSectorEcharts = () => {
  return http({
    url: WATER_CENSUS_YEAR_SECTOR_ECHARTS,
    method: 'GET'
  })
}

/**
 * 分页查询用户信息
 * @param {number} pageNum 当前页,必填
 * @param {number} pageSize  每页行数,必填
 * @param {number} roleId 角色ID
 * @param {string} adminPhone 用户手机号码
 * @returns
 */
export const queryPageAccount = params => {
  return http({
    url: QUERY_PAGE_ACCOUNT,
    method: 'GET',
    params
  })
}

/**
 * 查询所有角色
 */
export const getRoleAll = () => {
  return http({
    url: GET_ROLE,
    method: 'get'
  })
}
/**
 * 添加角色
 * @param {string} roleName 角色名称,必填
 * @param {string} roleTitle 标识符,必填
 * @returns
 */
export const addRole = params => {
  return http({
    url: ADD_ROLE,
    method: 'POST',
    params
  })
}
/**
 * 删除角色
 * @param {number} roleId 角色ID,必填
 * @returns
 */
export const deleteRole = params => {
  return http({
    url: DELETE_ROLE,
    method: 'GET',
    params
  })
}
/**
 * 查看角色拥有的权限
 * @param {number} roleId 角色ID,必填
 * @returns
 */
export const findRolePermissionById = params => {
  return http({
    url: FIND_ROLE_PERMISSION,
    method: 'GET',
    params
  })
}
/**
 * 给角色授权
 * @param {Array} menuIdArr 菜单编号,必填
 * @param {number} roleId 角色ID,必填
 * @returns
 */
export const updatePermission = params => {
  console.log(params)
  return http({
    url: UPDATE_PERMISSION,
    method: 'POST',
    params,
    // headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    paramsSerializer: {
      serialize: params => {
        // if (params.menuIdArr.length !== 0) {
        console.log('"!11"')
        return qs.stringify(params, { indices: false }) // 参数：false,显示为recordIds[]，ture:recordIds
        // } else {
        //   console.log('"!22"')
        //   return qs.stringify(params, { arrayFormat: 'brackets', strictNullHandling: true })
        //   // 参数是空数组时，必须带参数,
        // }
      }
    }
  })
}
